<script>
import instance from "@/api/axios";

export default {
  name: "courseComponent",
  props:{
    type:[String]
  },
  data() {
    return {
      list:[]
    }
  },
  methods:{},
  created() {
    instance.post('https://wkt.myhope365.com/weChat/applet/course/list/type',{
      type:this.type,
      pageNum:1,
      pageSize:5
    }).then((res) => {
      if(res.code === 0){
        this.list=res.rows
      }

      console.log(this.list)
    })
  }
}
</script>

<template>
<div class="box">
  <div class="course" v-for="item in list" :key="item.courseId">
    <div>
      <img :src="item.coverFileUrl" alt="">
    </div>
    <div>
      {{item.courseTitle}}
    </div>
    <div>
      {{ item.learningNum }}人学习
    </div>
    <div v-if="item.isFree==='1'">
      免费
    </div>
    <div v-else-if="item.isDiscount==='1'">
      <del>{{item.coursrPrice}}</del>{{item.discountPrice}}
    </div>
    <div v-else>
      {{item.coursrPrice}}
    </div>
  </div>

</div>
</template>

<style scoped lang="less">
.box {
  width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  .course{
    width: 18%;
    img{
      width: 100%;
    }
  }
}
</style>